
https://leetcode.cn/problems/next-greater-element-ii/?envType=daily-question&envId=2024-06-24
class fun{
public:
    bool operator()(pair<int,int>& p1,pair<int,int>& p2)
    {
        return p1.first>p2.first;
    }
};
class Solution {
public:
	vector<int> nextGreaterElements(vector<int>& nums) {
		vector<int>  ret(nums.size());
		priority_queue<pair<int, int>, vector<pair<int, int> >, fun > pq;
		int size = nums.size();
		for (int i = 0; i < size;i++) {
			nums.push_back(nums[i]);
		}
		for (int i = 0; i < 2*size; i++) {
			if(i<size)
				pq.push(make_pair(nums[i], i));
			while (pq.size() > 0 && nums[i] > pq.top().first) {
				auto e = pq.top(); pq.pop();
				ret[e.second] = nums[i];
			}
		}
		while (pq.size()) {
			ret[pq.top().second] = -1;
			pq.pop();
		}
		return ret;
	}
};